/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package videogest;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import persistencia.persistenciaCompra;

/**
 *
 * @author JAVA
 */
public class Compra extends Operacion {

    public Compra(Producto productos, Cliente cliente) throws FileNotFoundException, IOException {
        super(cliente, productos);
    }

    @Override
    public float calculaImporte() {
        return super.getProducto().getPrecioVenta();
    }

    @Override
    public String toString() {

        DateFormat df = new SimpleDateFormat("dd/MM/yyyy");

        String ret = "\n";
        ret += "================================================\n";
        ret += "|              DATOS DE COMPRA\n";
        ret += "================================================\n";
        ret += "|-- Codigo de la compra: " + super.getCodigo() + "\n";
        ret += "|-- Cliente: " + super.getCliente().getNombre() + "\n";
        ret += "|-- Producto: " + super.getProducto().getNombre() + "\n";
        ret += "|-- Fecha de compra: " + df.format(super.getFechaRegistro()) + "\n";
        ret += "================================================\n";

        return ret;
    }

    @Override
    public void alta() {

        persistenciaCompra.alta(this);

    }
}
